package com.humngyang.com.hmy.study.concurrency.myannoations.aqs;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.*;

public class FutureExample {
    private static Logger log = LoggerFactory.getLogger(FutureExample.class);
    static class MyCallable implements Callable<String> {
        @Override
        public String call() throws Exception {
            log.info(" do something in callalbe");
            Thread.sleep(3000);
            return "done";
        }
    }
    public static void main(String[] args) throws Exception{
        ExecutorService executorService = Executors.newCachedThreadPool();
        Future<String> submit = executorService.submit(new MyCallable());
        log.info("do something in main");
        Thread.sleep(1000);
        String result = submit.get();
        log.info("result {}",result);
//

    }
}
